<style>
    #storedetail{
        line-height: 36px;
        padding-left: 20px;
        padding-bottom: 10px;
    }
    #bf{
        background-color: #eee;
        text-align: right;
        width: 150px;
    }
    #cf{
        width: 200px;
    }
    #editdetail{
        font-size: 16px;
    }
    #editdetail tr{
        height: 42px;
    }
    #mf{
        background-color: #eee;
        text-align: right;
        width: 150px;
    }
    #nf{
        width: 170px;
    }
</style>
<?php
if($this->ma == 2){
    echo '<script language="javascript" type="text/javascript">alert("对不起，您选中的商品有的已经出库了或者等待出库！");location.href="/admini/managestore/index";</script>';
}else if($this->ma == 4){
    echo '<script language="javascript" type="text/javascript">alert("对不起，您选中的商品不属于同一个用户！");location.href="/admini/managestore/index";</script>';
}else if($this->ma == 1){
    echo '<script language="javascript" type="text/javascript">alert("国际运单添加成功！");location.href="/admini/managestore/index";</script>';
}
$weight = 0;
$volume = 0;
if ($this->store != '') {
    foreach ($this->store as $Item) {
        $weight = $weight+$Item->weight;
        $volume = $volume+$Item->volumeWeight;
        $userid = $Item->userid;
    }
}
?>
    	<div class="fapiaoleft">
            <div id="editdetail">
                <div >
                    <form method="post" action="/admini/managestore/launch/id/<?php echo $this->idlist;?>" id="formstore">
                        <div class="qdmcs">
                            <h2>添加收件人信息</h2>
                        </div>
                        <table width="800" border="1" cellpadding="0" cellspacing="0">
                            <tr>
                                <td id="mf">运单编号：</td>
                                <td id="nf">&nbsp;&nbsp;<input type="text" id="billNo" name="billNo" value="" /></td>
                                <td id="mf">预付款：</td>
                                <td id="nf">&nbsp;&nbsp;￥<input type="text" id="shipMoney" name="shipMoney" value="0" /></td>
                            </tr>
                            <tr>
                                <td id="mf">收件人姓名：</td>
                                <td id="nf">&nbsp;&nbsp;<input type="text" id="consignee" name="consignee" value="" /></td>
                                <td id="mf">目的国家：</td>
                                <td id="nf">&nbsp;&nbsp;<input type="hidden" name="state" id="state" value="1"/>
                                    <div style="position: relative;" id="state_div">
                                      <div class="guyojiatext"><?= $this->formText('cityName',"美国",array('readonly'=>true,'cid'=>1)) ?><a href="javascript:void(0)"></a></div>
                                      <div class="guojiaceng" style="display:none;top:15px;">
                                          <div class="remen">
                                              <h2>热门国家和地区</h2>
                                              <ul class="countrylist">
                                                  <li><a href="javascript:void(0)" id="c_us" cid="1">美国</a></li>
                                                  <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                                                  <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                                                  <li><a href="javascript:void(0)" cid="47">日本</a></li>
                                                  <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                                                  <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                                                  <li><a href="javascript:void(0)" cid="5">英国</a></li>
                                                  <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                                              </ul>
                                          </div>
                                          <div class="allcountry">
                                              <h2>全部国家和地区</h2>
                                              <ul class="countryzm">
                                                  <? foreach ($this->words as $char) { ?>
                                                      <li <?= $char == 'A' ? 'class="zmon"' : '' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                                                  <? } ?>
                                              </ul>
                                              <div id="countryTab">
                                                  <? foreach ($this->words as $char) { ?>
                                                      <ul class="countrylist"  <?= $char == 'A' ? '' : 'style="display:none"' ?>>
                                                          <?
                                                          $citys = Application_Model_city::GetBySortCode($char);
                                                          foreach ($citys as $city) {
                                                              ?>
                                                              <li><a href="javascript:void(0)" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                                      <? } ?>
                                                      </ul>
                                                 <? } ?>
                                              </div>
                                          </div>
                                      </div>
                                    </div></td>
                            </tr>
                            <tr>
                                <td id="mf">联系电话：</td>
                                <td id="nf">&nbsp;&nbsp;<input type="text" id="conTel" name="conTel" value="" /></td>
                                <td id="mf">邮政编码：</td>
                                <td id="nf">&nbsp;&nbsp;<input type="text" id="conPostCode" name="conPostCode" value="" /></td>
                            </tr>
                            <tr>
                                <td id="mf">收件人地址：</td>
                                <td id="nf" colspan="3">&nbsp;&nbsp;<textarea id="conAdd" name="conAdd" style="margin: 15px 0px 0px;width: 600px;height: 60px;"></textarea></td>
                            </tr>
                            <tr>
                                <td id="mf">发货渠道：</td>
                                <td id="nf" colspan="3">&nbsp;&nbsp;<select id="expressId" name="expressId">
                                        <?php foreach ($this->shiptype as $value) { ?>
                                            <option value="<?php echo $value->id; ?>"><?php echo $value->name;?></option>
                                        <?php }?>
                                    </select></td>
                            </tr>
                            <tr>
                                <td id="mf">体积重量：</td>
                                <td id="nf" >&nbsp;&nbsp;<input type="text" id="volumeWeight" name="volumeWeight" value="<?php echo $volume;?>" />g</td>
                                <td id="mf">物品净重：</td>
                                <td id="nf">&nbsp;&nbsp;<input type="text" id="productWeight" name="productWeight" value="<?php echo $weight;?>" />g</td>
                            </tr>
                            <tr>
                                <td id="mf">特殊操作：</td>
                                <td id="nf" colspan="3">&nbsp;&nbsp;
                                    <input type="checkbox" id="isCompress" name="isCompress" />&nbsp;真空
                                    <input type="checkbox" id="isNoSkin" name="isNoSkin" />&nbsp;去包装
                                    <input type="checkbox" id="isNoLogo" name="isNoLogo" />&nbsp;去吊牌
                                </td>
                            </tr>
                            <tr>
                                <td id="mf">备注：</td>
                                <td id="nf" colspan="3">&nbsp;&nbsp;<textarea id="remark" name="remark" style="margin: 15px 0px 0px;width: 600px;height: 60px;"></textarea></td>
                            </tr>
                            <tr>
                                <td colspan="5" height="55px;">
                                    <input type="hidden" id="storeid" name="storeid" value="<?php echo $this->idlist; ?>" />
                                    <input type="hidden" id="userid" name="userid" value="<?php echo $userid; ?>" />
                                    <input type="hidden" id="operate" name="operate" value="addbill" />
                                    <a href="javascript:void(0)" class="anvbotton4" id="redetail" style="margin-left:20px;"><span>取消添加</span></a>
                                    <a class="anvbotton" href="javascript:void(0)" id="substore" style="margin-left:20px;"><span>确认提交</span></a>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>           
        </div>     
<div class="fapiaoright">
    <div class="qdmcs">
        <h2>运单物品</h2>
    </div>
    <div id="sellist" style="" class="content">
        <iframe src="/admini/managestore/selstore/userid/<?php echo $userid;?>/id/<?php echo $this->idlist;?>" width="98%" id="iframeselstore" name="iframeselstore" frameBorder="0" scrolling="no"  onload="javascript:dyniframesize('iframeselstore');"></iframe>
        <a href="javascript:void(0)" class="anvbotton4" id="delbillid" style="margin-left:20px;"><span>删除</span></a>
    </div>
    <div class="qdmcs" style=" margin-top: 35px;">
        <h2>用户仓库其他物品</h2>
    </div>
    <div id="storelist" style="" class="content">
        <iframe src="/admini/managestore/userstore/userid/<?php echo $userid;?>/id/<?php echo $this->idlist;?>" width="98%" id="iframestore" name="iframestore" frameBorder="0" scrolling="no"  onload="javascript:dyniframesize('iframestore');"></iframe>
        <a href="javascript:void(0)" class="anvbotton4" id="addbillid" style="margin-left:20px;"><span>添加</span></a>
    </div>
</div>

<script type="text/javascript">
    $("#substore").click(function(){
        var billNo = $("#billNo").val();
        var shipMoney = $("#shipMoney").val();
        var consignee = $("#consignee").val();
        var conTel = $("#conTel").val();
        var conPostCode = $("#conPostCode").val();
        var productWeight = $("#productWeight").val();
        var bagWeight = $("#bagWeight").val();
        var conAdd = $("#conAdd").val();
        if(billNo == ""){
            alert("运单编号不能为空");
            return false;
        }else if(shipMoney == ""){
            alert("预付款不能为空");
            return false;
        }else if(consignee == ""){
            alert("收件人姓名不能为空");
            return false;
        }else if(conTel == ""){
            alert("收件人电话不能为空");
            return false;
        }else if(conPostCode == ""){
            alert("收件人邮编不能为空");
            return false;
        }else if(conAdd == ""){
            alert("收件人地址不能为空");
            return false;
        }else if(productWeight == ""){
            alert("包裹重量不能为空");
            return false;
        }else{
            $("#formstore").submit();
        }
    });
    $("#redetail").click(function(){
        location.href="/admini/managestore/index"; 
    });
    $("#storelist #addbillid").click(function(){
        var iframecon = document.getElementById("iframestore");
        var idlist = '';
        var storeid = iframecon.contentDocument.getElementsByName('storeid');
        
        $.each(storeid, function(key, val) {
            if(val.checked == true){
                idlist+= val.value+",";
            }
        });
        var delsrc = $("#iframestore").attr("src");
        $("#iframestore").attr("src",delsrc+idlist);
        var addsrc = $("#iframeselstore").attr("src");
        $("#iframeselstore").attr("src",addsrc+idlist);
        var addid = $("#storeid").val();
        addid = addid+idlist;
        $("#storeid").val(addid);
    });
    $("#sellist #delbillid").click(function(){
        var iframecon = document.getElementById("iframeselstore");
        var storeid = iframecon.contentDocument.getElementsByName('storeid');
        var delsrc = $("#iframeselstore").attr("src");
        var addsrc = $("#iframestore").attr("src");
        var delid = $("#storeid").val();
        $.each(storeid, function(key, val) {
            if(val.checked == true){
                var idval = val.value+",";
                delsrc=delsrc.replace(idval,"");
                addsrc=addsrc.replace(idval,"");
                delid=delid.replace(idval,"");
            }
        });
        $("#iframeselstore").attr("src",delsrc);
        $("#iframestore").attr("src",addsrc);
        $("#storeid").val(delid);
    });
    function dyniframesize(down) { 
        var pTar = null; 
        if (document.getElementById(down)){ 
            pTar = document.getElementById(down); 
        }else{ 
            eval('pTar = ' + down + ';'); 
        } 
        if (pTar && !window.opera){ 
            pTar.style.display="block" 
            if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){ 
                pTar.height = pTar.contentDocument.getElementById('bodystore').offsetHeight+5; 
                pTar.width = pTar.contentDocument.body.scrollWidth; 
            } else if (pTar.Document && pTar.Document.body.scrollHeight){ 
                pTar.height = pTar.Document.body.scrollHeight; 
                pTar.width = pTar.Document.body.scrollWidth; 
            } 
            
        } 
    } 
    $('#billNo').blur(function(){
        var billNo = $(this).val();
        if(billNo != ''){
            $.post('/admini/managestore/billdetail/', {'billNo':billNo}, function(data){
                if(data == 1){
                    alert("该运单编号已存在，请重新输入");
                    $("#billNo").val("");
                }
            }, 'json');
        }else{
            $('#username').attr('value','');
            $('#userId').attr('value','');
        }
    });
    $('#state_div').hover(function(){
    },function(){
        $('.guojiaceng').hide();
    }).click(function(){
        $('.guojiaceng').show();
    });
    $('.countrylist a').bind('click',function(){
        var city =$(this).text();
        var state = $(this).attr("cid");
        $("#state").val(state);
        $("#cityName").val(city);
        $('.guojiaceng').hide();
        return false;
    });
    $('.countryzm a').each(function(index,item){
        $(item).click(function(){
            $('.countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#countryTab ul').hide();
            $('#countryTab ul').eq(index).show();
            return false;
        });
    });
</script>